<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/7/17
 * Time: 12:42
 */

namespace app\home\controller;
use think\Controller;
use app\home\model\Login as Log;
class Login extends Controller {
    public function login(){
        if(request()->isPost()){
            $captcha = input('request.captcha');
            if(!captcha_check($captcha)){

                echo ("<script type='text/javascript'> alert('验证码错误');</script>");
            }else{
                $login = new Log;
                $status = $login->login(input('mobilenum'),input('userpass'));
                if($status==1){
                    return $this->redirect('Index/index');
                }elseif($status==2){
                    echo("<script type='text/javascript'> alert('账号或者密码错误！');</script>");

                }
                else{
                    echo("<script type='text/javascript'> alert('用户不存在！');</script>");

                }
            }
        }

        return $this->fetch();
    }
    public function logout(){
        session(null);//清空session
        return $this->success('注销成功！','Index/index');
    }


}